{% extends 'fanli.html' %}

{% block content-center %}
    <h3  class="page-header">1、磁盘空间大小监控</h3>
    <!-- 为 ECharts 准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 800px;height:600px;"></div>

    <h3  class="page-header">2、增量最多的表TOP20</h3>
    <div class='row'>
      <table class="table table-hover">
        <th>数据库</th>
        <th>表名</th>
        <th>行数</th>
        <th>当前</th>
        <th>昨天</th>
        <th>增量</th>

       {% for tablesize in tablesize%}
        <tr>
           <td> {{tablesize.DBNAME}} </td>
           <td> {{tablesize.TABLENAME}}</td>
           <td> {{tablesize.ROWS}}</td>
           <td> {{tablesize.today_size}}</td>
           <td> {{tablesize.lastday_size}}</td>
           <td> {{tablesize.incr}}</td>
        </tr>
        {%endfor%}
      </table>
    </div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        var xx = [];
        var yy = [];

        // 同步执行
        $.ajaxSettings.async = false;

        $.getJSON('/fanli/json_get_db_size', function (json) {
            xx = json.dt;
            yy01 = json.free_siz_min;
            yy02 = json.free_siz_max;
        });

        // alert(xx)

       // 指定图表的配置项和数据
        option = {
            title : {
                text: '',
                subtext: ''
            },
            legend: {
                data: ['最小磁盘空间[GB]','最大磁盘空间[GB]']
            },
            tooltip : {
                trigger: 'axis'
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false},
                    magicType : {show: true, type: ['line', 'bar']},
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    boundaryGap : false,
                    data : xx
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'最小磁盘空间[GB]',
                    type:'line',
                    data:yy01
                },
                {
                    name:'最大磁盘空间[GB]',
                    type:'line',
                    data:yy02
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
{% endblock %}